#!/bin/sh
# Created on 20100622 by Jimmy Wu
# Uses Mathematica to calculate a solution to the given gss
# and then uses gnuplot to create a svg visualization of the
# segments with solution vertices.
#
# Arguments:
#   $1:	gss file
#   $2:	matrix file
#   $3:	intersections file
#
# Environment:
#   CLASSPATH	must include FracToDouble
#
# Dependencies:
#   ilp_vertices.sh
#   f2d_gss_visualizer.sh

usage() {
    echo Usage: "$(basename "$0")" gss_file matrix_file intersections_file
}

if [ $# -lt 3 ] ; then
    usage >&2
    exit 1
fi

gss="$1"
matrix="$2"
intersections="$3"
base="${gss%.gss}"
solutions="$base.ilp.vertices"
pointcolor=red
visualizer=gss_visualizer.sh
fractodouble=gss.FracToDouble

ilp_vertices.sh "$matrix" "$intersections" > "$solutions"
java $fractodouble "$solutions" "$solutions".double
$visualizer "$gss" "$solutions".double $pointcolor
